import React, { useState, Dispatch, SetStateAction, MutableRefObject } from 'react'
import Chapter from '@/Model/Node/Chapter'

export interface IChapterContext{
  chapter:[Chapter, Dispatch<SetStateAction<Chapter>>],
  currentCard: [string, Dispatch<SetStateAction<string>>],
  refresh:[number, Dispatch<SetStateAction<number>>],
}

export const ChapterContext = React.createContext<IChapterContext>({} as IChapterContext)

export default function useChapterContext () {
  const ChapterContextState:IChapterContext = {
    chapter: useState<Chapter>(() => new Chapter()),
    currentCard: useState(''),
    refresh: useState(new Date().getTime())
  }
  return ChapterContextState
}
